package controllers

import (
	"go_skill_point/pkg/apiserver/controllers/v1/body_store"
	"go_skill_point/pkg/metrics"

	"github.com/gin-contrib/pprof"
	"github.com/gin-gonic/gin"
)

type Controller struct {
	Router              *gin.Engine
	bodyStoreController *body_store.BodyStoreController
}

func (c *Controller) Init() error {
	// c.Router = gin.Default()
	c.Router = gin.New()

	// 集成metrics
	metrics.Router(c.Router)

	// 集成pprof
	pprof.Register(c.Router)

	c.bodyStoreController = body_store.NewBodyStoreController()

	adminGroup := c.Router.Group("/body")
	{
		adminGroup.GET("/test1", c.bodyStoreController.Test1)
		adminGroup.GET("/test2", c.bodyStoreController.Test2)
		adminGroup.GET("/test3", c.bodyStoreController.Test3)
	}

	c.Router.Run(":8080")

	return nil
}
